package jude.java.framework.dao;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

import jude.java.money.beans.global.BaseBean;

import org.hibernate.type.Type;

public interface Dao {
	
	public <T extends BaseBean> void insert(T o);
	
	public <T extends BaseBean> void update(T o);
	/** 批量更新 */
	public <T extends BaseBean> int update(Class<T> clz, String hql, Object[] values);

	public <T extends BaseBean> void insertOrUpdate(T o);

	public <T extends BaseBean> void insertOrUpdateAll(Collection<T> o);
	
	public <T extends BaseBean> void delete(T o);

	public <T extends BaseBean>  void delete(Class<T> clazz, Serializable id);

	public <T extends BaseBean> T get(Class<T> clazz, Serializable id);
	
	public <T extends BaseBean> T get(Class<T> clazz, String key, Object value);

	public <T extends BaseBean> List<T> listAll(Class<T> clazz);

	public <T extends BaseBean> List<T> query(Class<T> clazz, String key, Object value);

	/**
	 * :array
	 * */
	public <T extends BaseBean> List<T> queryWithArray(Class<T> clazz, final int pageSize, final int pageIndex, String query, final Object array);
	
	/** 慎重使用 */
	@Deprecated
	public <T extends BaseBean> List<T> query(Class<T> clazz, String search, Object... values);
	
	public <T extends BaseBean> List<T> query(Class<T> clazz, String search, int pageSize, int pageIndex, Object[] values, Type[] types);
	
	public <T extends BaseBean> int count(Class<T> clazz, String search, Object[] values, Type[] types);
	
	/**
	 * 查询
	 * */
	public List<?> query(String hql);
	
	public <T extends BaseBean> List<T> queryBySql(String sql, Class<T> clz);
	
	/** @return List&lt;Object&gt; */
	public Object executeSql(final String sql);
	
	/** 仅一结果的查询, 更新(insert/update/delete/select count(*)/...) */
	public Object executeUniqueResultSql(final String sql);
	
	/**
	 * 获取唯一结果
	 * */
	public Object get(String hql);
	
	/**
	 * 更新
	 */
	public int update(String hql);
}
